package com.sunxueqi.project.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sunxueqi.framework.web.controller.BaseController;
import com.sunxueqi.framework.web.vo.ResponseData;
import com.sunxueqi.project.system.service.IDictInfoService;
import com.sunxueqi.project.system.vo.DictInfo;

import io.swagger.annotations.Api;

@Api(tags="数据字典详情信息")
@RestController
@RequestMapping("/system/dict/info")
public class DictInfoController extends BaseController{

	@Autowired
	private IDictInfoService dictInfoService;
	
	/**
	 * 根据数据字典类型获取对应的字典信息内容
	 * @param dictType
	 * @return
	 */
	@GetMapping("/dictType/{dictType}")
	public ResponseData list(@PathVariable String dictType) {
		startPage();
		List<DictInfo> list = dictInfoService.selectDictInfoByType(dictType);
		return ResponseData.successTableData(list);
	}
	
	/**
	 * 新增数据字典详情信息内容
	 * @param dictInfo
	 * @return
	 */
	@PostMapping
	public ResponseData add(@RequestBody DictInfo dictInfo) {
		return super.getResponseDataRow(dictInfoService.add(dictInfo));
	}
	
	/**
	 * 根据数据字典类型获取其下的所有数据详情
	 * @param dictInfo
	 * @return
	 */
	@GetMapping("/list")
	public ResponseData list(DictInfo dictInfo) {
		List<DictInfo> list = dictInfoService.selectDictInfoList(dictInfo);
		return ResponseData.successTableData(list);
	}
	
	
	/**
	 * 修改数据字典详情的状态
	 * @param dictInfo
	 * @return
	 */
	@PutMapping("/changeStatus")
	public ResponseData changeStatus(@RequestBody DictInfo dictInfo) {
		return getResponseDataRow(dictInfoService.changeStatus(dictInfo));
	}
	
	
}
